From: Florian Müllner Date: Fri, 20 Jul 2018 19:46:19 +0000 (+0200) Subject: messageTray: Drop tween helper function X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~839^2^2~64 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=213d10bf4ea539c028d8d9b01289e7600ac4cc01;p=gnome-shell.git messageTray: Drop tween helper function It makes the code harder to follow and saves little in terms of code duplication. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/654 --- diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js index 8fd19df8d..77d4364b0 100644 --- a/js/ui/messageTray.js +++ b/js/ui/messageTray.js @@ -1249,30 +1249,6 @@ var MessageTray = class MessageTray { this._notificationExpired = false; } - _tween(actor, statevar, value, params) { - let onComplete = params.onComplete; - let onCompleteScope = params.onCompleteScope; - let onCompleteParams = params.onCompleteParams; - - params.onComplete = this._tweenComplete; - params.onCompleteScope = this; - params.onCompleteParams = [statevar, value, onComplete, onCompleteScope, onCompleteParams]; - - // Remove other tweens that could mess with the state machine - Tweener.removeTweens(actor); - Tweener.addTween(actor, params); - - let valuing = (value == State.SHOWN) ? State.SHOWING : State.HIDING; - this[statevar] = valuing; - } - - _tweenComplete(statevar, value, onComplete, onCompleteScope, onCompleteParams) { - this[statevar] = value; - if (onComplete) - onComplete.apply(onCompleteScope, onCompleteParams); - this._updateState(); - } - _clampOpacity() { this._bannerBin.opacity = Math.max(0, Math.min(this._bannerBin._opacity, 255)); } @@ -1349,17 +1325,20 @@ var MessageTray = class MessageTray { // We use this._showNotificationCompleted() onComplete callback to extend the time the updated // notification is being shown. - let tweenParams = { y: 0, - _opacity: 255, - time: ANIMATION_TIME / 1000, - transition: 'easeOutBack', - onUpdate: this._clampOpacity, - onUpdateScope: this, - onComplete: this._showNotificationCompleted, - onCompleteScope: this - }; - - this._tween(this._bannerBin, '_notificationState', State.SHOWN, tweenParams); + this._notificationState = State.SHOWING; + Tweener.removeTweens(this._bannerBin); + Tweener.addTween(this._bannerBin, { + y: 0, + _opacity: 255, + time: ANIMATION_TIME / 1000, + transition: 'easeOutBack', + onUpdate: () => this._clampOpacity, + onComplete: () => { + this._notificationState = State.SHOWN; + this._showNotificationCompleted(); + this._updateState(); + } + }); } _showNotificationCompleted() { @@ -1419,16 +1398,20 @@ var MessageTray = class MessageTray { this._resetNotificationLeftTimeout(); if (animate) { - this._tween(this._bannerBin, '_notificationState', State.HIDDEN, - { y: -this._bannerBin.height, - _opacity: 0, - time: ANIMATION_TIME / 1000, - transition: 'easeOutBack', - onUpdate: this._clampOpacity, - onUpdateScope: this, - onComplete: this._hideNotificationCompleted, - onCompleteScope: this - }); + this._notificationState = State.HIDING; + Tweener.removeTweens(this._bannerBin); + Tweener.addTween(this._bannerBin, { + y: -this._bannerBin.height, + _opacity: 0, + time: ANIMATION_TIME / 1000, + transition: 'easeOutBack', + onUpdate: () => this._clampOpacity, + onComplete: () => { + this._notificationState = State.HIDDEN; + this._hideNotificationCompleted(); + this._updateState(); + } + }); } else { Tweener.removeTweens(this._bannerBin); this._bannerBin.y = -this._bannerBin.height;